/*
 * @Description:
 * @Author: zheng yiliang
 * @Date: 2021-04-19 22:04:08
 * @LastEditTime: 2021-05-29 19:50:24
 * @LastEditors: zheng yiliang
 */
import request from '@/utils/request'

// 添加文章
export function addArticle (data) {
  return request({
    url: '/article/add',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

// 查询文章
export function getArticles (data) {
  return request({
    url: '/article/all',
    method: 'get',
    params: data
  })
}

// 查询文章
export function getArticlesDetail (id) {
  return request({
    url: '/article/detail',
    method: 'get',
    params: { id }
  })
}

// 删除文章
export function delArticles (id) {
  return request({
    url: '/article/del',
    method: 'delete',
    data: { id }
  })
}

// 修改文章
export function editArticles (data) {
  return request({
    url: '/article/edit',
    method: 'put',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

// 新增二级评论
export const replyComments = req => {
  return request.post('/article/replyComments', req)
}

// 根据文章id查询评论
export const commentsByArticle = req => {
  return request.get('/article/commentsByArticle', { params: { article_id: req } })
}

export function replyRead (data) {
  return request({
    url: '/article/replyRead',
    method: 'put',
    data
  })
}

export function read (data) {
  return request({
    url: '/article/read',
    method: 'put',
    data
  })
}

export function allRead (data) {
  return request({
    url: '/article/allRead',
    method: 'put',
    data
  })
}

export function delReplyComment (data) {
  return request({
    url: '/article/delReplyComment',
    method: 'delete',
    data
  })
}
export function delComment (data) {
  return request({
    url: '/article/delComment',
    method: 'delete',
    data
  })
}
